package com.zwz.service.impl;

import com.zwz.entity.Trademark;
import com.zwz.mapper.TrademarkMapper;
import com.zwz.service.TrademarkService;
import com.zwz.voObject.Know;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TrademarkServiceImpl implements TrademarkService {

    @Autowired
    private TrademarkMapper trademarkMapper;

    @Override
    public void createTrademark(Trademark trademark,String enterpriseId) {
        validateTrademark(trademark);
        trademark.setEnterpriseId(enterpriseId);
        trademarkMapper.insert(trademark);
    }

    @Override
    public void updateTrademark(Trademark trademark) {

    }

    @Override
    public void deleteTrademark(String id) {

    }

    @Override
    public Trademark getById(String id) {
        return null;
    }

    private void validateTrademark(Trademark trademark) {
        if (trademark.getRegNumber() == null || trademark.getRegNumber().isEmpty()) {
            throw new IllegalArgumentException("商标注册号不能为空");
        }
//        if (trademark.getApplicationTime() == null) {
//            throw new IllegalArgumentException("申请时间必须填写");
//        }
    }

    @Override
    public List<Trademark> getByCompany(String companyName) {
        return trademarkMapper.selectByCompany(companyName);
    }

    @Override
    public List<Trademark> searchByStatus(String status) {
        return null;
    }

    @Override
    public List<Know> getKnowInfo(String id) {
        return trademarkMapper.getKnowInfo(id);
    }

    // 其他方法实现...
}